/*     */ package com.yc.dao;
/*     */ 
/*     */ import btsm.bean.dbConnector;
/*     */ import com.yc.dao.model.FileBO;
/*     */ import com.yc.util.ListContentsBFO;
/*     */ import java.sql.ResultSet;
/*     */ import java.sql.SQLException;
/*     */ import java.text.SimpleDateFormat;
/*     */ import java.util.ArrayList;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.Iterator;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import java.util.Set;
/*     */ import org.apache.commons.logging.Log;
/*     */ import org.apache.commons.logging.LogFactory;
/*     */ 
/*     */ public class FileDAO
/*     */ {
/*  24 */   private static final Log log = LogFactory.getLog(FileDAO.class);
/*     */ 
/*  26 */   private dbConnector dbcon = null;
/*  27 */   private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
/*     */ 
/*     */   private void dbConInit() {
/*  30 */     if (this.dbcon == null)
/*  31 */       this.dbcon = new dbConnector();
/*     */   }
/*     */ 
/*     */   public void dbConClose() {
/*  35 */     if (this.dbcon != null)
/*  36 */       this.dbcon.closeAll();
/*  37 */     this.dbcon = null;
/*     */   }
/*     */ 
/*     */   public String getFolderPath(String strParentFolderID)
/*     */   {
/*  43 */     log.debug("查询父文件夹路径");
/*  44 */     dbConInit();
/*  45 */     String strSQL = "select other1 from folder where folderID = '" + strParentFolderID + "'";
/*  46 */     ResultSet rs = null;
/*  47 */     String strParentFolderPath = null;
/*     */     try
/*     */     {
/*  50 */       strSQL = new String(strSQL.getBytes("ISO8859-1"), "UTF-8");
/*  51 */       rs = this.dbcon.execQuery(strSQL);
/*  52 */       if (rs.next())
/*  53 */         strParentFolderPath = rs.getString("other1");
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/*  57 */       e.printStackTrace();
/*     */     }
/*  59 */     dbConClose();
/*  60 */     return strParentFolderPath;
/*     */   }
/*     */ 
/*     */   public String getFilePath(String strFileID)
/*     */   {
/*  70 */     dbConInit();
/*  71 */     log.info("query file path ...[begin]...");
/*  72 */     ResultSet rs = null;
/*  73 */     String strFilePath = null;
/*     */     try
/*     */     {
/*  76 */       String strSQL = "select filePath from filedetail where fileID = '" + strFileID + "'";
/*  77 */       strSQL = new String(strSQL.getBytes("ISO8859-1"), "UTF-8");
/*  78 */       log.info(strSQL);
/*  79 */       rs = this.dbcon.execQuery(strSQL);
/*  80 */       if (rs.next())
/*  81 */         strFilePath = rs.getString("filePath");
/*     */     }
/*     */     catch (Exception e) {
/*  84 */       e.printStackTrace();
/*     */     }
/*  86 */     dbConClose();
/*  87 */     log.info("query file path ...[end]...");
/*  88 */     return strFilePath;
/*     */   }
/*     */ 
/*     */   public boolean deleteFile(String strFileID)
/*     */   {
/*  94 */     dbConInit();
/*  95 */     log.info("delete file path ...[begin]...");
/*  96 */     boolean boolReturn = true;
/*     */     try
/*     */     {
/*  99 */       String strSQL = "delete  from filedetail where fileID = '" + strFileID + "'";
/* 100 */       strSQL = new String(strSQL.getBytes("ISO8859-1"), "UTF-8");
/* 101 */       log.info(strSQL);
/* 102 */       this.dbcon.execUpdate(strSQL);
/*     */     }
/*     */     catch (Exception e) {
/* 105 */       boolReturn = false;
/* 106 */       e.printStackTrace();
/*     */     }
/* 108 */     dbConClose();
/* 109 */     log.info("delete file path ...[end]...");
/* 110 */     return boolReturn;
/*     */   }
/*     */ 
/*     */   public boolean deleteFileByPath(String strFolderID)
/*     */   {
/* 120 */     dbConInit();
/* 121 */     log.info("delete file path ...[begin]...");
/* 122 */     boolean boolReturn = true;
/*     */     try
/*     */     {
/* 125 */       String strSQL = "delete  from filedetail where folderId = '" + strFolderID + "'";
/* 126 */       strSQL = new String(strSQL.getBytes("ISO8859-1"), "UTF-8");
/* 127 */       log.info(strSQL);
/* 128 */       this.dbcon.execUpdate(strSQL);
/*     */     }
/*     */     catch (Exception e) {
/* 131 */       boolReturn = false;
/* 132 */       e.printStackTrace();
/*     */     }
/* 134 */     dbConClose();
/* 135 */     log.info("delete file path ...[end]...");
/* 136 */     return boolReturn;
/*     */   }
/*     */ 
/*     */   public boolean setFileShare(FileBO bo)
/*     */   {
/* 146 */     log.debug("set [" + bo.getFileId() + "] file share ");
/* 147 */     boolean boolFlag = true;
/* 148 */     dbConInit();
/*     */     try
/*     */     {
/* 151 */       Date shareBeginTime = bo.getShareBeginTime();
/* 152 */       Date shareEndTime = bo.getShareEndTime();
/* 153 */       StringBuffer buf = new StringBuffer();
/* 154 */       boolean isShare = isShare(shareBeginTime, shareEndTime);
/* 155 */       if ((shareBeginTime != null) && (shareEndTime != null))
/*     */       {
/* 157 */         buf.append("update filedetail set shareBeginTime= '" + this.sdf.format(bo.getShareBeginTime()) + "', ");
/* 158 */         buf.append(" shareEndTime = '" + this.sdf.format(bo.getShareEndTime()) + "' ,");
/* 159 */         buf.append(" isShare = '" + isShare + "' ");
/* 160 */         buf.append(" where fileID = '" + bo.getFileId() + "'");
/* 161 */       } else if ((shareBeginTime != null) && (shareEndTime == null))
/*     */       {
/* 163 */         buf.append("update filedetail set shareBeginTime= '" + this.sdf.format(bo.getShareBeginTime()) + "' ,");
/* 164 */         buf.append(" isShare = '" + isShare + "' ");
/* 165 */         buf.append(" where fileID = '" + bo.getFileId() + "'");
/*     */       }
/* 167 */       else if ((shareBeginTime == null) && (shareEndTime != null))
/*     */       {
/* 169 */         buf.append("update filedetail set  ");
/* 170 */         buf.append(" shareEndTime = '" + this.sdf.format(bo.getShareEndTime()) + "',");
/* 171 */         buf.append(" isShare = '" + isShare + "' ");
/* 172 */         buf.append(" where fileID = '" + bo.getFileId() + "'");
/*     */       }
/*     */       else {
/* 175 */         buf.append("update filedetail set  ");
/* 176 */         buf.append(" isShare = 'false' ");
/* 177 */         buf.append(" where fileID = '" + bo.getFileId() + "'");
/*     */       }
/* 179 */       String strSQL = buf.toString();
/* 180 */       strSQL = new String(strSQL.getBytes("ISO8859-1"), "UTF-8");
/* 181 */       log.info(strSQL);
/* 182 */       this.dbcon.execUpdate(strSQL);
/*     */     }
/*     */     catch (Exception e) {
/* 185 */       boolFlag = false;
/* 186 */       e.printStackTrace();
/* 187 */       log.error(e.getMessage());
/*     */     }
/* 189 */     dbConClose();
/* 190 */     return boolFlag;
/*     */   }
/*     */ 
/*     */   public boolean renameFileName(FileBO bo)
/*     */   {
/* 196 */     log.info(" file rename ");
/* 197 */     boolean flag = true;
/*     */     try
/*     */     {
/* 200 */       dbConInit();
/* 201 */       String strSQL = "update filedetail set filePath = '" + bo.getFilePath() + "', fileName = '" + bo.getFileName() + "' where fileId = '" + bo.getFileId() + "'";
/* 202 */       log.info(strSQL);
/* 203 */       this.dbcon.execUpdate(strSQL);
/*     */     }
/*     */     catch (Exception e) {
/* 206 */       e.printStackTrace();
/* 207 */       log.error(e.getMessage());
/* 208 */       flag = false;
/*     */     }
/* 210 */     dbConClose();
/* 211 */     return flag;
/*     */   }
/*     */ 
/*     */   public List getAllFileSize(String strUserID) throws SQLException
/*     */   {
/* 216 */     log.info("query [" + strUserID + "]'s files size ");
/* 217 */     dbConInit();
/* 218 */     List sizeList = new ArrayList();
/* 219 */     ResultSet rs = null;
/*     */     try
/*     */     {
/* 222 */       String strSQL = "select fileSize from filedetail where userID =  '" + strUserID + "'";
/* 223 */       strSQL = new String(strSQL.getBytes("ISO8859-1"), "UTF-8");
/* 224 */       log.info(strSQL);
/* 225 */       rs = this.dbcon.execQuery(strSQL);
/* 226 */       while (rs.next())
/*     */       {
/* 228 */         sizeList.add(rs.getString("fileSize"));
/*     */       }
/*     */     } catch (Exception re) {
/* 231 */       log.error("save failed", re);
/* 232 */       re.printStackTrace();
/*     */     }
/*     */     finally {
/* 235 */       if (rs != null)
/* 236 */         rs.close();
/*     */     }
/* 238 */     dbConClose();
/* 239 */     return sizeList;
/*     */   }
/*     */ 
/*     */   public void saveFile(FileBO bo)
/*     */   {
/* 244 */     dbConInit();
/* 245 */     log.debug("saving FileBO instance");
/*     */     try {
/* 247 */       StringBuffer sqlBuffer = new StringBuffer();
/* 248 */       if (bo.getShareBeginTime() != null)
/* 249 */         sqlBuffer.append("insert into filedetail(fileID,fileName,folderID,userID,filePath,isShare,uploadTime,fileSize,shareBeginTime) ");
/*     */       else
/* 251 */         sqlBuffer.append("insert into filedetail(fileID,fileName,folderID,userID,filePath,isShare,uploadTime,fileSize) ");
/* 252 */       sqlBuffer.append(" values ( ");
/* 253 */       sqlBuffer.append("'" + bo.getFileId() + "',");
/* 254 */       sqlBuffer.append("'" + bo.getFileName() + "',");
/* 255 */       sqlBuffer.append("'" + bo.getFolderId() + "',");
/* 256 */       sqlBuffer.append("'" + bo.getUserId() + "',");
/* 257 */       sqlBuffer.append("'" + bo.getFilePath() + "',");
/* 258 */       sqlBuffer.append("'" + bo.getIsShare() + "',");
/* 259 */       sqlBuffer.append("'" + this.sdf.format(bo.getUploadTime()) + "',");
/* 260 */       if (bo.getShareBeginTime() != null)
/*     */       {
/* 262 */         sqlBuffer.append("'" + bo.getFileSize() + "',");
/* 263 */         sqlBuffer.append("'" + this.sdf.format(bo.getShareBeginTime()) + "')");
/*     */       } else {
/* 265 */         sqlBuffer.append("'" + bo.getFileSize() + "')");
/*     */       }
/* 267 */       String addsql = sqlBuffer.toString();
/* 268 */       log.info(addsql);
/*     */ 
/* 270 */       log.info(addsql);
/* 271 */       this.dbcon.execUpdate(addsql);
/* 272 */       log.debug("save successful");
/*     */     } catch (Exception re) {
/* 274 */       log.error("save failed", re);
/* 275 */       re.printStackTrace();
/*     */     }
/* 277 */     dbConClose();
/*     */   }
/*     */ 
/*     */   private void printMap(Map map)
/*     */   {
/* 282 */     Iterator iterator = map.keySet().iterator();
/* 283 */     while (iterator.hasNext())
/*     */     {
/* 285 */       Object objKey = iterator.next();
/* 286 */       log.info("******[" + objKey.toString() + ":" + map.get(objKey) + "]");
/*     */     }
/*     */   }
/*     */ 
/*     */   private String getSumSQL(Map condition)
/*     */   {
/* 297 */     String strId = condition.get("id").toString();
/* 298 */     String strUserID = condition.get("strUserID").toString();
/* 299 */     Object queryObj = condition.get("query");
/* 300 */     String strSQL = "";
/* 301 */     if ("otherRooot".equalsIgnoreCase(strId))
/*     */     {
/* 303 */       strSQL = "select count(fileName) from filedetail where userId != '" + strUserID + "' and userId != '" + "system" + "' and isShare = 'true'";
/* 304 */       if (queryObj != null)
/*     */       {
/* 306 */         strSQL = "select count(fileName) from filedetail where userId != '" + strUserID + "' and userId != '" + "system" + "' and isShare = 'true'" + 
/* 307 */           " and binary ucase(fileName) like concat('%',ucase('" + queryObj.toString() + "'),'%')";
/*     */       }
/*     */     }
/*     */     else
/*     */     {
/* 312 */       strSQL = "select count(fileName) from filedetail where folderID = '" + strId + "'";
/* 313 */       if (queryObj != null)
/*     */       {
/* 315 */         strSQL = "select count(fileName) from filedetail where folderID = '" + strId + "' " + 
/* 316 */           " and binary ucase(fileName) like concat('%',ucase('" + queryObj.toString() + "'),'%')";
/*     */       }
/*     */     }
/* 319 */     return strSQL;
/*     */   }
/*     */ 
/*     */   private Map getSQL(Map condition)
/*     */   {
/* 329 */     String strId = condition.get("id").toString();
/* 330 */     String strUserID = condition.get("strUserID").toString();
/* 331 */     int start = Integer.parseInt(condition.get("start").toString());
/* 332 */     int limit = Integer.parseInt(condition.get("limit").toString());
/* 333 */     Object queryObj = condition.get("query");
/* 334 */     String strSQL = "";
/* 335 */     Map map = new HashMap();
/* 336 */     boolean isSelfQuery = false;
/* 337 */     if ("otherRooot".equalsIgnoreCase(strId))
/*     */     {
/* 339 */       strSQL = "select fileID,fileName,isShare,uploadTime,shareBeginTime,shareEndTime from filedetail where isShare='true' and userID != '" + 
/* 340 */         strUserID + "' and userId != '" + "system" + "' limit " + start + ", " + limit;
/* 341 */       if (queryObj != null)
/*     */       {
/* 343 */         strSQL = "select fileID,fileName,isShare,uploadTime,shareBeginTime,shareEndTime from filedetail where isShare='true' and userID != '" + 
/* 344 */           strUserID + "' and userId != '" + "system" + "'" + 
/* 345 */           " and binary ucase(fileName) like concat('%',ucase('" + queryObj.toString() + "'),'%')" + 
/* 346 */           " limit " + start + ", " + limit;
/*     */       }
/* 348 */     } else if ("root".equalsIgnoreCase(strId))
/*     */     {
/* 350 */       strSQL = "select fileID,fileName,isShare,uploadTime,shareBeginTime,shareEndTime from filedetail where folderID='" + 
/* 351 */         strId + "' limit " + start + ", " + limit;
/* 352 */       if (queryObj != null)
/*     */       {
/* 354 */         strSQL = "select fileID,fileName,isShare,uploadTime,shareBeginTime,shareEndTime from filedetail where folderID='" + 
/* 355 */           strId + "' " + 
/* 356 */           " and binary ucase(fileName) like concat('%',ucase('" + queryObj.toString() + "'),'%')" + 
/* 357 */           " limit " + start + ", " + limit;
/*     */       }
/*     */     }
/*     */     else
/*     */     {
/* 362 */       strSQL = "select fileID,fileName,isShare,uploadTime,shareBeginTime,shareEndTime from filedetail where folderID='" + 
/* 363 */         strId + "' and userID = '" + strUserID + "' limit " + start + ", " + limit;
/* 364 */       if (queryObj != null)
/*     */       {
/* 366 */         strSQL = "select fileID,fileName,isShare,uploadTime,shareBeginTime,shareEndTime from filedetail where folderID='" + 
/* 367 */           strId + "' and userID = '" + strUserID + "' " + 
/* 368 */           " and binary ucase(fileName) like concat('%',ucase('" + queryObj.toString() + "'),'%')" + 
/* 369 */           " limit " + start + ", " + limit;
/*     */       }
/* 371 */       isSelfQuery = true;
/*     */     }
/* 373 */     map.put("strSQL", strSQL);
/* 374 */     map.put("isSelfQuery", String.valueOf(isSelfQuery));
/*     */ 
/* 376 */     return map;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getContents(Map condition)
/*     */   {
/* 386 */     String strId = condition.get("id").toString();
/* 387 */     log.info(" query files by [ " + strId + " ] folder id .");
/* 388 */     String strUserID = condition.get("strUserID").toString();
/* 389 */     dbConInit();
/* 390 */     ListContentsBFO bfo = new ListContentsBFO();
/* 391 */     int start = Integer.parseInt(condition.get("start").toString());
/* 392 */     int limit = Integer.parseInt(condition.get("limit").toString());
/*     */ 
/* 394 */     printMap(condition);
/*     */ 
/* 397 */     ResultSet rs = null;
/* 398 */     List fileList = new ArrayList();
/*     */     try
/*     */     {
/* 401 */       String strSQL = getSumSQL(condition);
/*     */ 
/* 403 */       log.info(strSQL);
/* 404 */       rs = this.dbcon.execQuery(strSQL);
/* 405 */       if (rs.next()) {
/* 406 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/* 408 */       Map sqlMap = getSQL(condition);
/* 409 */       strSQL = sqlMap.get("strSQL").toString();
/* 410 */       boolean isSelfQuery = Boolean.parseBoolean(sqlMap.get("isSelfQuery").toString());
/*     */ 
/* 412 */       log.info(strSQL);
/* 413 */       log.debug("isSelfQuery = " + isSelfQuery);
/* 414 */       rs = this.dbcon.execQuery(strSQL);
/*     */ 
/* 416 */       Date shareBeginTime = null;
/* 417 */       Date shareEndTime = null;
/* 418 */       while (rs.next())
/*     */       {
/* 420 */         FileBO bo = new FileBO();
/* 421 */         bo.setFileId(rs.getString("fileID"));
/* 422 */         bo.setId(rs.getString("fileID"));
/* 423 */         bo.setFileName(rs.getString("fileName"));
/* 424 */         bo.setUserId(strUserID);
/* 425 */         bo.setUploadTime(rs.getDate("uploadTime"));
/* 426 */         shareBeginTime = rs.getDate("shareBeginTime");
/* 427 */         shareEndTime = rs.getDate("shareEndTime");
/* 428 */         bo.setShareBeginTime(shareBeginTime);
/* 429 */         bo.setShareEndTime(shareEndTime);
/* 430 */         if (isSelfQuery)
/* 431 */           bo.setIsShare("true");
/*     */         else
/* 433 */           bo.setIsShare(String.valueOf(isShare(shareBeginTime, shareEndTime)));
/* 434 */         fileList.add(bo);
/*     */       }
/* 436 */       bfo.setData(fileList.toArray());
/*     */     }
/*     */     catch (Exception e) {
/* 439 */       e.printStackTrace();
/* 440 */       log.error("query file failed .");
/*     */     }
/*     */     finally {
/* 443 */       dbConClose();
/*     */     }
/* 445 */     return bfo;
/*     */   }
/*     */ 
/*     */   private String getComSumSQL(Map condition)
/*     */   {
/* 452 */     String strId = condition.get("id").toString();
/* 453 */     Object queryObj = condition.get("query");
/* 454 */     String strSQL = "";
/* 455 */     strSQL = "select count(fileName) from filedetail where folderID = '" + strId + "'";
/* 456 */     if (queryObj != null)
/*     */     {
/* 458 */       strSQL = "select count(fileName) from filedetail where folderID = '" + strId + "' " + 
/* 459 */         " and binary ucase(fileName) like concat('%',ucase('" + queryObj.toString() + "'),'%')";
/*     */     }
/* 461 */     return strSQL;
/*     */   }
/*     */ 
/*     */   private String getComSQL(Map condition)
/*     */   {
/* 472 */     String strId = condition.get("id").toString();
/* 473 */     int start = Integer.parseInt(condition.get("start").toString());
/* 474 */     int limit = Integer.parseInt(condition.get("limit").toString());
/* 475 */     Object queryObj = condition.get("query");
/* 476 */     String strSQL = "";
/* 477 */     strSQL = "select fileID,fileName,isShare,uploadTime,shareBeginTime,shareEndTime from filedetail where folderID='" + 
/* 478 */       strId + "' limit " + start + ", " + limit;
/* 479 */     if (queryObj != null)
/*     */     {
/* 481 */       strSQL = "select fileID,fileName,isShare,uploadTime,shareBeginTime,shareEndTime from filedetail where folderID='" + 
/* 482 */         strId + "' " + 
/* 483 */         " and binary ucase(fileName) like concat('%',ucase('" + queryObj.toString() + "'),'%')" + 
/* 484 */         " limit " + start + ", " + limit;
/*     */     }
/*     */ 
/* 487 */     return strSQL;
/*     */   }
/*     */ 
/*     */   public ListContentsBFO getComContents(Map condition)
/*     */   {
/* 492 */     String strId = condition.get("id").toString();
/* 493 */     log.info(" query files by [ " + strId + " ] folder id .");
/* 494 */     String strUserID = condition.get("strUserID").toString();
/* 495 */     dbConInit();
/* 496 */     ListContentsBFO bfo = new ListContentsBFO();
/* 497 */     int start = Integer.parseInt(condition.get("start").toString());
/* 498 */     int limit = Integer.parseInt(condition.get("limit").toString());
/*     */ 
/* 500 */     printMap(condition);
/*     */ 
/* 503 */     ResultSet rs = null;
/* 504 */     List fileList = new ArrayList();
/*     */     try
/*     */     {
/* 507 */       String strSQL = getComSumSQL(condition);
/*     */ 
/* 509 */       log.info(strSQL);
/* 510 */       rs = this.dbcon.execQuery(strSQL);
/* 511 */       if (rs.next()) {
/* 512 */         bfo.setTotalSize(rs.getInt(1));
/*     */       }
/* 514 */       strSQL = getComSQL(condition);
/*     */ 
/* 516 */       log.info(strSQL);
/* 517 */       rs = this.dbcon.execQuery(strSQL);
/*     */ 
/* 519 */       Date shareBeginTime = null;
/* 520 */       Date shareEndTime = null;
/* 521 */       while (rs.next())
/*     */       {
/* 523 */         FileBO bo = new FileBO();
/* 524 */         bo.setFileId(rs.getString("fileID"));
/* 525 */         bo.setId(rs.getString("fileID"));
/* 526 */         bo.setFileName(rs.getString("fileName"));
/* 527 */         bo.setUserId(strUserID);
/* 528 */         bo.setUploadTime(rs.getDate("uploadTime"));
/* 529 */         shareBeginTime = rs.getDate("shareBeginTime");
/* 530 */         shareEndTime = rs.getDate("shareEndTime");
/* 531 */         bo.setShareBeginTime(shareBeginTime);
/* 532 */         bo.setShareEndTime(shareEndTime);
/* 533 */         bo.setIsShare(String.valueOf(isShare(shareBeginTime, shareEndTime)));
/* 534 */         fileList.add(bo);
/*     */       }
/* 536 */       bfo.setData(fileList.toArray());
/*     */     }
/*     */     catch (Exception e) {
/* 539 */       e.printStackTrace();
/* 540 */       log.error("query file failed .");
/*     */     }
/*     */     finally {
/* 543 */       dbConClose();
/*     */     }
/* 545 */     return bfo;
/*     */   }
/*     */ 
/*     */   private boolean isShare(Date shareBeginTime, Date shareEndTime)
/*     */   {
/* 552 */     if (shareBeginTime == null)
/* 553 */       return false;
/* 554 */     if (shareBeginTime != null)
/*     */     {
/* 556 */       Date nowTime = new Date();
/* 557 */       if (shareBeginTime.compareTo(nowTime) <= 0)
/*     */       {
/* 559 */         if (shareEndTime != null)
/*     */         {
/* 561 */           if (shareEndTime.compareTo(nowTime) > 0) {
/* 562 */             return true;
/*     */           }
/* 564 */           return false;
/*     */         }
/* 566 */         return true;
/*     */       }
/*     */ 
/* 569 */       if (shareEndTime == null)
/*     */       {
/* 571 */         if (shareBeginTime.compareTo(nowTime) > 0) {
/* 572 */           return false;
/*     */         }
/* 574 */         return true;
/*     */       }
/*     */ 
/* 577 */       if (shareEndTime.compareTo(nowTime) > 0) {
/* 578 */         return false;
/*     */       }
/* 580 */       return true;
/*     */     }
/*     */ 
/* 584 */     return true;
/*     */   }
/*     */ 
/*     */   public String queryMaxFileID()
/*     */   {
/* 597 */     dbConInit();
/* 598 */     ResultSet rs = null;
/* 599 */     String strQueryMaxSQLWhere = "";
/* 600 */     String strQueryMaxSQL = "";
/* 601 */     String strMaxNo = "";
/* 602 */     String strMatch = "";
/* 603 */     String strDjJc = "File";
/* 604 */     long lLshCd = 4L;
/*     */     try
/*     */     {
/* 608 */       for (int i = 0; i < lLshCd; i++)
/*     */       {
/* 610 */         strMatch = strMatch + "_";
/*     */       }
/*     */ 
/* 613 */       Date nowTime = new Date();
/* 614 */       SimpleDateFormat fmtDate = null;
/* 615 */       fmtDate = new SimpleDateFormat("yyyyMMdd");
/* 616 */       String strDate = fmtDate.format(nowTime);
/* 617 */       strQueryMaxSQLWhere = strDjJc + strDate;
/* 618 */       strQueryMaxSQL = "select max(fileID) as strMaxNo from filedetail where fileID like '" + strQueryMaxSQLWhere + 
/* 619 */         strMatch + "' ";
/*     */ 
/* 621 */       strQueryMaxSQL = new String(strQueryMaxSQL.getBytes("ISO8859-1"), "UTF-8");
/* 622 */       log.debug("strQueryMaxSQL = [" + strQueryMaxSQL + "]");
/* 623 */       rs = this.dbcon.execQuery(strQueryMaxSQL);
/* 624 */       if (rs.next())
/*     */       {
/* 626 */         strMaxNo = rs.getString("strMaxNo");
/*     */       }
/* 628 */       if (rs != null)
/*     */       {
/* 630 */         rs.close();
/* 631 */         rs = null;
/*     */       }
/*     */ 
/* 635 */       if ((strMaxNo == null) || (strMaxNo.equals("")) || 
/* 636 */         (strMaxNo.length() != strQueryMaxSQLWhere.length() + lLshCd))
/*     */       {
/* 638 */         for (int i = 1; i < lLshCd; i++)
/*     */         {
/* 640 */           strQueryMaxSQLWhere = strQueryMaxSQLWhere + "0";
/*     */         }
/* 642 */         strMaxNo = strQueryMaxSQLWhere + "1";
/* 643 */         log.debug("是第一个编号=" + strMaxNo);
/*     */       }
/*     */       else
/*     */       {
/* 649 */         long lLshValue = Long.valueOf(
/* 650 */           strMaxNo.substring((int)(strMaxNo.length() - lLshCd), strMaxNo.length())).longValue() + 1L;
/*     */ 
/* 652 */         String strLshBh = String.valueOf(lLshValue);
/*     */ 
/* 654 */         for (int i = strLshBh.length(); i < lLshCd; i++)
/*     */         {
/* 656 */           strLshBh = "0" + strLshBh;
/*     */         }
/* 658 */         strMaxNo = strQueryMaxSQLWhere + strLshBh;
/* 659 */         log.debug("如果不是第一个编号=" + strMaxNo);
/*     */       }
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 664 */       e.printStackTrace();
/*     */       try
/*     */       {
/* 670 */         if (rs != null)
/*     */         {
/* 672 */           rs.close();
/* 673 */           rs = null;
/*     */         }
/*     */       }
/*     */       catch (Exception ex)
/*     */       {
/* 678 */         ex.printStackTrace();
/*     */       }
/*     */     }
/*     */     finally
/*     */     {
/*     */       try
/*     */       {
/* 670 */         if (rs != null)
/*     */         {
/* 672 */           rs.close();
/* 673 */           rs = null;
/*     */         }
/*     */       }
/*     */       catch (Exception ex)
/*     */       {
/* 678 */         ex.printStackTrace();
/*     */       }
/*     */     }
/* 681 */     dbConClose();
/* 682 */     return strMaxNo;
/*     */   }
/*     */ }

/* Location:           E:\java\apache-tomcat-6.0.36\webapps\btsm\WEB-INF\classes\
 * Qualified Name:     com.yc.dao.FileDAO
 * JD-Core Version:    0.6.2
 */